package com.leemon.mall.sys.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.leemon.mall.sys.model.SysLog;
import com.leemon.mall.sys.service.SysLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 系统日志 前端控制器
 * </p>
 *
 * @author leemon
 * @since 2019-09-04
 */
@Api(tags = "后台-系统日志接口", description = "系统日志")
@RestController
@RequestMapping("/sys/log")
public class SysLogController {

    @Autowired
    private SysLogService sysLogService;

    @GetMapping("/page")
    @ApiOperation("系统日志列表")
    public ResponseEntity page(SysLog sysLog, Page<SysLog> page) {
        IPage<SysLog> logIPage = sysLogService.page(page, new LambdaQueryWrapper<SysLog>()
                .like(StringUtils.isNotBlank(sysLog.getUsername()), SysLog::getUsername, sysLog.getUsername())
                .like(StringUtils.isNotBlank(sysLog.getOperation()), SysLog::getMethod, sysLog.getOperation()));
        return ResponseEntity.ok(logIPage);
    }

}

